﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MySoftLab.DapFlashCore.Probes.DapAccess.Interfaces
{
    public abstract class DapInterface
    {
        public const int DEFAULT_USB_TIMEOUT_S = 10;
        public const int DEFAULT_USB_TIMEOUT_MS = DEFAULT_USB_TIMEOUT_S * 1000;

        public virtual bool HasSwoEp
        {
            get
            {
                return false;
            }
        }

        public virtual bool IsBulk
        {
            get
            {
                return false;
            }
        }

        public abstract uint Vid
        {
            get;
        }

        public abstract uint Pid
        {
            get;
        }

        public abstract string VendorName
        {
            get;
        }

        public abstract string ProductName
        {
            get;
        }

        public abstract void Open();

        public abstract void Close();

        public abstract byte[] Read();

        public abstract void Write(byte[] data);

        public abstract uint ReadSwo();

        private int _packetSize = 64;
        public virtual int PacketSize
        {
            get
            {
                return _packetSize;
            }

            set
            {
                _packetSize = value;
            }
        }

        private int _packetCount = 1;

        public virtual int PacketCount
        {
            get
            {
                return _packetCount;
            }

            set
            {
                _packetCount = value;
            }
        }

        public abstract string SerialNumber
        {
            get;
        }

        public virtual string GetInfo()
        {
            return VendorName + " " + ProductName + " (" + Vid.ToString("X") + ", " + Pid.ToString("X") + ")";
        }

        public virtual void SetPacketCount(int count)
        {
            _packetCount = count;
        }
    }
}
